# coding:utf-8

from threading import Thread
import requests
import time

class post_thread(Thread):

    def __init__(self, *args, **kwargs):
        Thread.__init__(self)
        self.args = args
        self.kwargs = kwargs

    def run(self):
        print 'post started...' + self.args[1]
        requests.post(self.args[0], self.kwargs)
        time.sleep(10)

for i in range(10):
    mypost = post_thread('http://127.0.0.1:5000/sendmail',
                         'thread%d' %i,
                         to='zidanesandy@163.com',
                         contents='这是我发的第%d封邮件' % i)
    mypost.run()